#ifndef __JCTO_SOCKET_H__
#define __JCTO_SOCKET_H__

#include "JctoYing.h"

#if defined(_WIN32)

typedef SOCKET JctoSocketHandle;

#elif defined(__APPLE__)||defined(__linux__)

typedef int JctoSocketHandle;

#endif

typedef enum
{
    JCTO_SOCKET_STATUS_OK,
    JCTO_SOCKET_STATUS_START_FAILED,
    JCTO_SOCKET_STATUS_IP_ERROR,
    JCTO_SOCKET_STATUS_FAMILY_ERROR,
    JCTO_SOCKET_STATUS_CONNECT_ERROR,
}JctoSocketStatus;

extern void jctoSocketStart(void);
extern JctoSocketStatus jctoSocketOpenTcp(JctoSocketHandle*handle,const char ip[],int port);
extern unsigned int jctoSocketSend(JctoSocketHandle*handle,const unsigned char data[],unsigned int len);
extern int jctoSocketRecv(JctoSocketHandle*handle,unsigned char data[],unsigned int len);
extern void jctoSocketClose(JctoSocketHandle*handle);

#endif